import { WebMiddleware, ConsoleMiddleware } from '../plugins/Plugin';
import { noop } from '../utils/noop';
import { PluginManager } from './PluginManager';
import { Composer } from '../utils/compose';

export abstract class Controller {
  private readonly pluginManager: PluginManager;
  protected prefix: string = '';
  protected actions: () => void = noop;

  constructor(pluginManager: PluginManager) {
    this.pluginManager = pluginManager;
  }

  public/*protected*/ getManager(): PluginManager {
    return this.pluginManager;
  }

  public/*protected*/ setPrefix(prefix: string = this.prefix): void {
    this.prefix = prefix;
  }

  public/*protected*/ setActions(actions: () => void): void {
    this.actions = actions;
  }

  public/*protected*/ registerActions(): void {
    this.actions.call(this);
  }

  public/*protected*/ abstract createMiddleware(globalToLocal?: Composer): WebMiddleware | ConsoleMiddleware;
}
